package com.zztl.infiniteBand.ui.activity

import android.content.Intent
import android.net.Uri
import android.text.Spannable
import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.style.ForegroundColorSpan
import android.text.style.URLSpan
import android.view.View
import com.zztl.infiniteBand.R
import com.zztl.infiniteBand.base.BaseActivity
import com.zztl.infiniteBand.model.ContactInfoBean
import com.zztl.infiniteBand.storage.BillPreference
import com.zztl.infiniteBand.storage.PreferenceKeys
import com.zztl.infiniteBand.util.AppInfoUtils
import kotlinx.android.synthetic.main.activity_about_us.*

class AboutUsActivity : BaseActivity() {


    override fun setLayoutId(): Int = R.layout.activity_about_us


    override fun initBase() {
        setTitle(getString(R.string.关于我们))
        tv_version.text = "V" + AppInfoUtils.appVersionName
        BillPreference.getObjFromSp<ContactInfoBean.DataBean>(PreferenceKeys.CONTACTINFO.name)?.apply {
            website?.let { mWebsite ->
//                mWebsite.lastIndexOf("/")?.let { index ->
                    val spStr = SpannableString(getString(R.string.official_website) + mWebsite)
                    //设置超链接
                    spStr.setSpan(URLSpan(mWebsite), getString(R.string.official_website).length-1, spStr.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
                    //设置字体前景色
                    spStr.setSpan(ForegroundColorSpan(resources.getColor(R.color.color_bb999999)), 5, spStr.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
                    //        spStr.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.color_01BB3C)), 1,3, Spanned.SPAN_EXCLUSIVE_INCLUSIVE); //设置前景色为洋红色


                    tv_net_address.text = spStr
//                tv_net_address.setOnClickListener { openUrl(mWebsite) }
                tv_net_address.movementMethod = LinkMovementMethod.getInstance()
            }
        }

    }

}
